home *** CD-ROM | disk | FTP | other *** search
/ Macwelt 4 / Macwelt DVD 4.cdr / Internet / Internet-Utilities / Mac-OS X / darkstat-2.2 / src / darkstat.c < prev    next >
MacBinary  |  2002-09-23  |  9.4 KB  |  [□□□□/□□□□]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert Compact Compressed (Unix) (archive/compact) ext Supported
1% dexvert MacBinary (archive/macBinary) fallback Supported
100% file MacBinary II, inited, Mon Sep 23 04:13:20 2002, modified Mon Sep 23 04:13:20 2002, 8988 bytes "darkstat.c" , at 0x239c 286 bytes resource default (weak)
99% file data default
100% TrID MacBinary 2 default (weak)
100% dearkID deark: macbinary default
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default
100% librempegprobeID NGC (Nintendo DSP Standard) (ngcdspstd) default (weak)


id metadata
keyvalue
macFileType[□□□□]
macFileCreator[□□□□]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 0a 64 61 72 6b 73 74 | 61 74 2e 63 00 00 00 00 |..darkst|at.c....|
|00000010| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 00 00 00 00 00 00 00 | 00 01 00 00 00 00 00 00 |........|........|
|00000050| 00 00 00 00 00 23 1c 00 | 00 01 1e b9 b4 7d a0 b9 |.....#..|.....}..|
|00000060| b4 7d a0 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |.}......|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 c1 81 00 00 |........|........|
|00000080| 0a 2f 2a 20 64 61 72 6b | 73 74 61 74 3a 20 61 20 |./* dark|stat: a |
|00000090| 6e 65 74 77 6f 72 6b 20 | 74 72 61 66 66 69 63 20 |network |traffic |
|000000a0| 61 6e 61 6c 79 7a 65 72 | 0a 20 2a 20 28 63 29 20 |analyzer|. * (c) |
|000000b0| 32 30 30 31 2d 32 30 30 | 32 2c 20 45 6d 69 6c 20 |2001-200|2, Emil |
|000000c0| 4d 69 6b 75 6c 69 63 2e | 0a 20 2a 2f 0a 0a 2f 2a |Mikulic.|. */../*|
|000000d0| 20 45 76 65 72 79 74 68 | 69 6e 67 20 68 65 72 65 | Everyth|ing here|
|000000e0| 20 69 73 20 63 6f 76 65 | 72 65 64 20 62 79 20 74 | is cove|red by t|
|000000f0| 68 65 20 47 50 4c 20 28 | 73 65 65 20 74 68 65 20 |he GPL (|see the |
|00000100| 27 43 4f 50 59 49 4e 47 | 27 20 66 69 6c 65 29 20 |'COPYING|' file) |
|00000110| 2a 2f 0a 0a 23 69 6e 63 | 6c 75 64 65 20 22 64 61 |*/..#inc|lude "da|
|00000120| 72 6b 73 74 61 74 2e 68 | 22 0a 23 69 6e 63 6c 75 |rkstat.h|".#inclu|
|00000130| 64 65 20 22 68 6f 73 74 | 5f 64 62 2e 68 22 0a 23 |de "host|_db.h".#|
|00000140| 69 6e 63 6c 75 64 65 20 | 22 70 6f 72 74 5f 64 62 |include |"port_db|
|00000150| 2e 68 22 0a 23 69 6e 63 | 6c 75 64 65 20 22 70 72 |.h".#inc|lude "pr|
|00000160| 6f 74 6f 2e 68 22 0a 23 | 69 6e 63 6c 75 64 65 20 |oto.h".#|include |
|00000170| 22 62 69 67 6e 75 6d 2e | 68 22 0a 23 69 6e 63 6c |"bignum.|h".#incl|
|00000180| 75 64 65 20 22 61 63 63 | 74 2e 68 22 0a 23 69 6e |ude "acc|t.h".#in|
|00000190| 63 6c 75 64 65 20 22 64 | 6e 73 2e 68 22 0a 23 69 |clude "d|ns.h".#i|
|000001a0| 6e 63 6c 75 64 65 20 22 | 77 77 77 2e 68 22 0a 23 |nclude "|www.h".#|
|000001b0| 69 6e 63 6c 75 64 65 20 | 22 67 72 61 70 68 2e 68 |include |"graph.h|
|000001c0| 22 0a 23 69 6e 63 6c 75 | 64 65 20 22 73 70 79 6c |".#inclu|de "spyl|
|000001d0| 6f 67 2e 68 22 0a 0a 23 | 69 6e 63 6c 75 64 65 20 |og.h"..#|include |
|000001e0| 3c 73 79 73 2f 74 79 70 | 65 73 2e 68 3e 0a 23 69 |<sys/typ|es.h>.#i|
|000001f0| 6e 63 6c 75 64 65 20 3c | 73 79 73 2f 73 6f 63 6b |nclude <|sys/sock|
|00000200| 65 74 2e 68 3e 0a 23 69 | 6e 63 6c 75 64 65 20 3c |et.h>.#i|nclude <|
|00000210| 73 79 73 2f 69 6f 63 74 | 6c 2e 68 3e 0a 23 69 6e |sys/ioct|l.h>.#in|
|00000220| 63 6c 75 64 65 20 3c 6e | 65 74 69 6e 65 74 2f 69 |clude <n|etinet/i|
|00000230| 6e 2e 68 3e 0a 23 69 6e | 63 6c 75 64 65 20 3c 6e |n.h>.#in|clude <n|
|00000240| 65 74 2f 69 66 2e 68 3e | 0a 23 69 6e 63 6c 75 64 |et/if.h>|.#includ|
|00000250| 65 20 3c 61 72 70 61 2f | 69 6e 65 74 2e 68 3e 0a |e <arpa/|inet.h>.|
|00000260| 23 69 6e 63 6c 75 64 65 | 20 3c 70 63 61 70 2e 68 |#include| <pcap.h|
|00000270| 3e 0a 0a 23 69 6e 63 6c | 75 64 65 20 3c 61 73 73 |>..#incl|ude <ass|
|00000280| 65 72 74 2e 68 3e 0a 23 | 69 6e 63 6c 75 64 65 20 |ert.h>.#|include |
|00000290| 3c 73 74 64 69 6f 2e 68 | 3e 0a 23 69 6e 63 6c 75 |<stdio.h|>.#inclu|
|000002a0| 64 65 20 3c 73 74 64 6c | 69 62 2e 68 3e 0a 23 69 |de <stdl|ib.h>.#i|
|000002b0| 6e 63 6c 75 64 65 20 3c | 73 74 64 61 72 67 2e 68 |nclude <|stdarg.h|
|000002c0| 3e 0a 23 69 6e 63 6c 75 | 64 65 20 3c 73 69 67 6e |>.#inclu|de <sign|
|000002d0| 61 6c 2e 68 3e 0a 23 69 | 6e 63 6c 75 64 65 20 3c |al.h>.#i|nclude <|
|000002e0| 75 6e 69 73 74 64 2e 68 | 3e 0a 23 69 6e 63 6c 75 |unistd.h|>.#inclu|
|000002f0| 64 65 20 3c 73 74 72 69 | 6e 67 2e 68 3e 0a 23 69 |de <stri|ng.h>.#i|
|00000300| 6e 63 6c 75 64 65 20 3c | 74 69 6d 65 2e 68 3e 0a |nclude <|time.h>.|
|00000310| 23 69 66 20 64 65 66 69 | 6e 65 64 28 73 75 6e 29 |#if defi|ned(sun)|
|00000320| 20 26 26 20 28 64 65 66 | 69 6e 65 64 28 5f 5f 73 | && (def|ined(__s|
|00000330| 76 72 34 5f 5f 29 20 7c | 7c 20 64 65 66 69 6e 65 |vr4__) ||| define|
|00000340| 64 28 5f 5f 53 56 52 34 | 29 29 20 0a 23 69 6e 63 |d(__SVR4|)) .#inc|
|00000350| 6c 75 64 65 20 3c 73 79 | 73 2f 73 6f 63 6b 69 6f |lude <sy|s/sockio|
|00000360| 2e 68 3e 0a 23 65 6e 64 | 69 66 0a 23 69 6e 63 6c |.h>.#end|if.#incl|
|00000370| 75 64 65 20 3c 6c 6f 63 | 61 6c 65 2e 68 3e 0a 0a |ude <loc|ale.h>..|
|00000380| 69 6e 74 09 76 65 72 62 | 6f 73 65 20 3d 20 30 2c |int.verb|ose = 0,|
|00000390| 20 77 65 62 70 6f 72 74 | 20 3d 20 44 45 46 41 55 | webport| = DEFAU|
|000003a0| 4c 54 5f 57 45 42 50 4f | 52 54 2c 20 77 61 6e 74 |LT_WEBPO|RT, want|
|000003b0| 5f 73 70 79 20 3d 20 30 | 2c 0a 09 77 65 62 69 70 |_spy = 0|,..webip|
|000003c0| 20 3d 20 44 45 46 41 55 | 4c 54 5f 57 45 42 49 50 | = DEFAU|LT_WEBIP|
|000003d0| 2c 20 73 68 75 74 74 69 | 6e 67 5f 64 6f 77 6e 20 |, shutti|ng_down |
|000003e0| 3d 20 30 2c 20 70 72 6f | 6d 69 73 63 20 3d 20 31 |= 0, pro|misc = 1|
|000003f0| 3b 0a 63 68 61 72 09 2a | 65 72 72 64 62 5f 66 69 |;.char.*|errdb_fi|
|00000400| 6c 65 20 3d 20 4e 55 4c | 4c 2c 20 2a 64 62 5f 66 |le = NUL|L, *db_f|
|00000410| 69 6c 65 20 3d 20 4e 55 | 4c 4c 2c 20 2a 64 61 79 |ile = NU|LL, *day|
|00000420| 6c 6f 67 5f 66 69 6c 65 | 20 3d 20 4e 55 4c 4c 2c |log_file| = NULL,|
|00000430| 0a 09 2a 66 70 72 65 66 | 69 78 20 3d 20 4e 55 4c |..*fpref|ix = NUL|
|00000440| 4c 2c 20 2a 61 63 63 74 | 64 65 76 20 3d 20 4e 55 |L, *acct|dev = NU|
|00000450| 4c 4c 2c 20 2a 61 63 63 | 74 65 78 70 72 20 3d 20 |LL, *acc|texpr = |
|00000460| 4e 55 4c 4c 3b 0a 70 74 | 68 72 65 61 64 5f 74 20 |NULL;.pt|hread_t |
|00000470| 77 77 77 5f 74 68 72 65 | 61 64 20 3d 20 4e 55 4c |www_thre|ad = NUL|
|00000480| 4c 2c 20 64 6e 73 5f 74 | 68 72 65 61 64 20 3d 20 |L, dns_t|hread = |
|00000490| 4e 55 4c 4c 2c 0a 09 20 | 20 73 70 79 5f 74 68 72 |NULL,.. | spy_thr|
|000004a0| 65 61 64 20 3d 20 4e 55 | 4c 4c 2c 20 61 63 63 74 |ead = NU|LL, acct|
|000004b0| 5f 74 68 72 65 61 64 20 | 3d 20 4e 55 4c 4c 3b 0a |_thread |= NULL;.|
|000004c0| 69 6e 74 20 75 70 5f 61 | 63 63 74 3d 30 2c 20 75 |int up_a|cct=0, u|
|000004d0| 70 5f 77 77 77 3d 30 2c | 20 75 70 5f 64 6e 73 3d |p_www=0,| up_dns=|
|000004e0| 30 2c 20 75 70 5f 73 70 | 79 3d 30 3b 0a 0a 0a 0a |0, up_sp|y=0;....|
|000004f0| 63 68 61 72 20 2a 62 75 | 69 6c 64 5f 73 74 72 28 |char *bu|ild_str(|
|00000500| 63 68 61 72 20 2a 66 6f | 72 6d 61 74 2c 20 2e 2e |char *fo|rmat, ..|
|00000510| 2e 29 0a 7b 0a 09 76 61 | 5f 6c 69 73 74 20 76 61 |.).{..va|_list va|
|00000520| 3b 0a 09 63 68 61 72 20 | 62 75 66 5b 31 30 32 34 |;..char |buf[1024|
|00000530| 5d 2c 20 2a 73 3b 0a 09 | 69 6e 74 20 63 6f 75 6e |], *s;..|int coun|
|00000540| 74 3b 0a 0a 09 76 61 5f | 73 74 61 72 74 28 76 61 |t;...va_|start(va|
|00000550| 2c 20 66 6f 72 6d 61 74 | 29 3b 0a 09 63 6f 75 6e |, format|);..coun|
|00000560| 74 20 3d 20 76 73 6e 70 | 72 69 6e 74 66 28 62 75 |t = vsnp|rintf(bu|
|00000570| 66 2c 20 31 30 32 34 2c | 20 66 6f 72 6d 61 74 2c |f, 1024,| format,|
|00000580| 20 76 61 29 3b 0a 0a 09 | 69 66 20 28 63 6f 75 6e | va);...|if (coun|
|00000590| 74 20 3d 3d 20 2d 31 29 | 20 66 72 65 61 6b 6f 75 |t == -1)| freakou|
|000005a0| 74 28 22 62 75 66 66 65 | 72 20 6f 76 65 72 66 6c |t("buffe|r overfl|
|000005b0| 6f 77 20 69 6e 20 62 75 | 69 6c 64 5f 73 74 72 28 |ow in bu|ild_str(|
|000005c0| 29 22 29 3b 0a 09 76 61 | 5f 65 6e 64 28 76 61 29 |)");..va|_end(va)|
|000005d0| 3b 0a 0a 09 73 20 3d 20 | 73 74 72 64 75 70 28 62 |;...s = |strdup(b|
|000005e0| 75 66 29 3b 0a 09 69 66 | 20 28 21 73 29 20 66 72 |uf);..if| (!s) fr|
|000005f0| 65 61 6b 6f 75 74 28 22 | 72 61 6e 20 6f 75 74 20 |eakout("|ran out |
|00000600| 6f 66 20 6d 65 6d 6f 72 | 79 20 69 6e 20 62 75 69 |of memor|y in bui|
|00000610| 6c 64 5f 73 74 72 28 29 | 22 29 3b 0a 09 72 65 74 |ld_str()|");..ret|
|00000620| 75 72 6e 20 73 3b 0a 7d | 0a 0a 0a 0a 76 6f 69 64 |urn s;.}|....void|
|00000630| 20 66 72 65 61 6b 6f 75 | 74 28 63 6f 6e 73 74 20 | freakou|t(const |
|00000640| 63 68 61 72 20 2a 65 72 | 72 29 0a 7b 0a 09 70 72 |char *er|r).{..pr|
|00000650| 69 6e 74 66 28 22 5c 6e | 46 61 74 61 6c 20 65 72 |intf("\n|Fatal er|
|00000660| 72 6f 72 3a 20 25 73 5c | 6e 5c 6e 22 2c 20 65 72 |ror: %s\|n\n", er|
|00000670| 72 29 3b 0a 0a 09 73 61 | 76 65 5f 64 62 28 65 72 |r);...sa|ve_db(er|
|00000680| 72 64 62 5f 66 69 6c 65 | 29 3b 0a 09 70 72 69 6e |rdb_file|);..prin|
|00000690| 74 66 28 22 44 79 69 6e | 67 20 6e 6f 77 2e 2e 2e |tf("Dyin|g now...|
|000006a0| 5c 6e 22 29 3b 0a 09 65 | 78 69 74 28 45 58 49 54 |\n");..e|xit(EXIT|
|000006b0| 5f 46 41 49 4c 29 3b 0a | 7d 0a 0a 0a 0a 76 6f 69 |_FAIL);.|}....voi|
|000006c0| 64 20 70 72 69 6e 74 5f | 61 64 64 72 28 63 6f 6e |d print_|addr(con|
|000006d0| 73 74 20 64 77 6f 72 64 | 20 69 70 29 0a 7b 0a 09 |st dword| ip).{..|
|000006e0| 70 72 69 6e 74 66 28 22 | 25 64 2e 25 64 2e 25 64 |printf("|%d.%d.%d|
|000006f0| 2e 25 64 22 2c 0a 09 09 | 28 69 70 20 3e 3e 20 32 |.%d",...|(ip >> 2|
|00000700| 34 29 20 26 20 32 35 35 | 2c 0a 09 09 28 69 70 20 |4) & 255|,...(ip |
|00000710| 3e 3e 20 31 36 29 20 26 | 20 32 35 35 2c 0a 09 09 |>> 16) &| 255,...|
|00000720| 28 69 70 20 3e 3e 20 38 | 29 20 26 20 32 35 35 2c |(ip >> 8|) & 255,|
|00000730| 0a 09 09 28 69 70 20 26 | 20 32 35 35 29 20 29 3b |...(ip &| 255) );|
|00000740| 0a 7d 0a 0a 0a 0a 73 74 | 61 74 69 63 20 52 45 54 |.}....st|atic RET|
|00000750| 53 49 47 54 59 50 45 20 | 74 65 72 6d 5f 73 69 67 |SIGTYPE |term_sig|
|00000760| 6e 61 6c 28 69 6e 74 20 | 73 69 67 6e 75 6d 29 0a |nal(int |signum).|
|00000770| 7b 0a 09 69 66 20 28 73 | 68 75 74 74 69 6e 67 5f |{..if (s|hutting_|
|00000780| 64 6f 77 6e 29 0a 09 7b | 0a 09 09 70 72 69 6e 74 |down)..{|...print|
|00000790| 66 28 22 43 61 75 67 68 | 74 20 61 20 72 65 64 75 |f("Caugh|t a redu|
|000007a0| 6e 64 61 6e 74 20 53 49 | 47 54 45 52 4d 2e 20 53 |ndant SI|GTERM. S|
|000007b0| 74 69 6c 6c 20 77 61 69 | 74 69 6e 67 20 66 6f 72 |till wai|ting for|
|000007c0| 3a 20 22 29 3b 0a 09 09 | 69 66 20 28 75 70 5f 61 |: ");...|if (up_a|
|000007d0| 63 63 74 29 20 70 72 69 | 6e 74 66 28 22 61 63 63 |cct) pri|ntf("acc|
|000007e0| 74 20 22 29 3b 0a 09 09 | 69 66 20 28 75 70 5f 64 |t ");...|if (up_d|
|000007f0| 6e 73 29 20 70 72 69 6e | 74 66 28 22 64 6e 73 20 |ns) prin|tf("dns |
|00000800| 22 29 3b 0a 09 09 69 66 | 20 28 75 70 5f 77 77 77 |");...if| (up_www|
|00000810| 29 20 70 72 69 6e 74 66 | 28 22 77 77 77 20 22 29 |) printf|("www ")|
|00000820| 3b 0a 09 09 69 66 20 28 | 75 70 5f 73 70 79 29 20 |;...if (|up_spy) |
|00000830| 70 72 69 6e 74 66 28 22 | 73 70 79 20 22 29 3b 0a |printf("|spy ");.|
|00000840| 09 09 70 72 69 6e 74 66 | 28 22 5c 6e 22 29 3b 0a |..printf|("\n");.|
|00000850| 09 09 72 65 74 75 72 6e | 3b 0a 09 7d 0a 0a 09 70 |..return|;..}...p|
|00000860| 72 69 6e 74 66 28 22 43 | 61 75 67 68 74 20 53 49 |rintf("C|aught SI|
|00000870| 47 54 45 52 4d 2c 20 73 | 79 6e 63 69 6e 67 20 74 |GTERM, s|yncing t|
|00000880| 68 72 65 61 64 73 2e 2e | 2e 5c 6e 22 29 3b 0a 09 |hreads..|.\n");..|
|00000890| 73 68 75 74 74 69 6e 67 | 5f 64 6f 77 6e 20 3d 20 |shutting|_down = |
|000008a0| 31 3b 0a 09 70 75 74 63 | 68 61 72 28 31 30 29 3b |1;..putc|har(10);|
|000008b0| 20 2f 2a 20 62 72 65 61 | 6b 20 6f 75 74 20 6f 66 | /* brea|k out of|
|000008c0| 20 64 6f 5f 6e 6f 74 68 | 69 6e 67 20 2a 2f 0a 7d | do_noth|ing */.}|
|000008d0| 0a 0a 0a 0a 69 6e 74 20 | 6d 61 69 6e 28 69 6e 74 |....int |main(int|
|000008e0| 20 61 72 67 63 2c 20 63 | 68 61 72 20 2a 2a 61 72 | argc, c|har **ar|
|000008f0| 67 76 29 0a 7b 0a 09 63 | 68 61 72 20 2a 73 70 79 |gv).{..c|har *spy|
|00000900| 64 65 76 2c 20 65 72 72 | 5b 50 43 41 50 5f 45 52 |dev, err|[PCAP_ER|
|00000910| 52 42 55 46 5f 53 49 5a | 45 5d 3b 0a 09 69 6e 74 |RBUF_SIZ|E];..int|
|00000920| 20 69 3b 0a 09 0a 09 73 | 65 74 6c 6f 63 61 6c 65 | i;....s|etlocale|
|00000930| 28 4c 43 5f 41 4c 4c 2c | 20 22 22 29 3b 0a 09 73 |(LC_ALL,| "");..s|
|00000940| 65 74 6c 6f 63 61 6c 65 | 28 4c 43 5f 4e 55 4d 45 |etlocale|(LC_NUME|
|00000950| 52 49 43 2c 20 22 65 6e | 5f 55 53 22 29 3b 0a 23 |RIC, "en|_US");.#|
|00000960| 69 66 20 45 4e 41 42 4c | 45 5f 4e 4c 53 0a 09 62 |if ENABL|E_NLS..b|
|00000970| 69 6e 64 74 65 78 74 64 | 6f 6d 61 69 6e 28 50 41 |indtextd|omain(PA|
|00000980| 43 4b 41 47 45 2c 20 4c | 4f 43 41 4c 45 44 49 52 |CKAGE, L|OCALEDIR|
|00000990| 29 3b 0a 09 74 65 78 74 | 64 6f 6d 61 69 6e 28 50 |);..text|domain(P|
|000009a0| 41 43 4b 41 47 45 29 3b | 0a 09 62 69 6e 64 5f 74 |ACKAGE);|..bind_t|
|000009b0| 65 78 74 64 6f 6d 61 69 | 6e 5f 63 6f 64 65 73 65 |extdomai|n_codese|
|000009c0| 74 28 50 41 43 4b 41 47 | 45 2c 20 22 55 54 46 2d |t(PACKAG|E, "UTF-|
|000009d0| 38 22 29 3b 0a 23 65 6e | 64 69 66 0a 0a 09 70 72 |8");.#en|dif...pr|
|000009e0| 69 6e 74 66 28 50 41 43 | 4b 41 47 45 20 22 20 76 |intf(PAC|KAGE " v|
|000009f0| 22 20 56 45 52 53 49 4f | 4e 20 22 20 75 73 69 6e |" VERSIO|N " usin|
|00000a00| 67 20 6c 69 62 70 63 61 | 70 20 76 25 64 2e 25 64 |g libpca|p v%d.%d|
|00000a10| 5c 6e 22 2c 0a 09 09 50 | 43 41 50 5f 56 45 52 53 |\n",...P|CAP_VERS|
|00000a20| 49 4f 4e 5f 4d 41 4a 4f | 52 2c 20 50 43 41 50 5f |ION_MAJO|R, PCAP_|
|00000a30| 56 45 52 53 49 4f 4e 5f | 4d 49 4e 4f 52 29 3b 0a |VERSION_|MINOR);.|
|00000a40| 0a 09 6c 6f 63 61 6c 5f | 69 70 20 3d 20 30 3b 0a |..local_|ip = 0;.|
|00000a50| 0a 09 2f 2a 20 68 61 6e | 64 6c 65 20 63 6f 6d 6d |../* han|dle comm|
|00000a60| 61 6e 64 6c 69 6e 65 20 | 61 72 67 75 6d 65 6e 74 |andline |argument|
|00000a70| 73 20 2a 2f 0a 09 66 6f | 72 20 28 69 3d 31 3b 20 |s */..fo|r (i=1; |
|00000a80| 69 3c 61 72 67 63 3b 20 | 69 2b 2b 29 0a 09 7b 0a |i<argc; |i++)..{.|
|00000a90| 09 09 69 66 20 28 28 73 | 74 72 63 6d 70 28 61 72 |..if ((s|trcmp(ar|
|00000aa0| 67 76 5b 69 5d 2c 20 22 | 2d 68 22 29 20 3d 3d 20 |gv[i], "|-h") == |
|00000ab0| 30 29 20 7c 7c 0a 09 09 | 09 28 73 74 72 63 6d 70 |0) ||...|.(strcmp|
|00000ac0| 28 61 72 67 76 5b 69 5d | 2c 20 22 2d 2d 68 65 6c |(argv[i]|, "--hel|
|00000ad0| 70 22 29 20 3d 3d 20 30 | 29 29 0a 09 09 7b 0a 09 |p") == 0|))...{..|
|00000ae0| 09 09 70 72 69 6e 74 66 | 28 0a 22 75 73 61 67 65 |..printf|(."usage|
|00000af0| 3a 20 25 73 20 5b 2d 69 | 20 3c 69 66 3e 5d 20 5b |: %s [-i| <if>] [|
|00000b00| 2d 70 20 3c 6e 75 6d 62 | 65 72 3e 5d 20 5b 2d 62 |-p <numb|er>] [-b|
|00000b10| 20 3c 69 70 3e 5d 20 5b | 2d 64 20 3c 70 61 74 68 | <ip>] [|-d <path|
|00000b20| 3e 5d 5c 6e 22 0a 22 5c | 74 5b 2d 6c 20 3c 69 70 |>]\n"."\|t[-l <ip|
|00000b30| 3e 2f 3c 6d 61 73 6b 3e | 5d 20 5b 2d 66 20 3c 69 |>/<mask>|] [-f <i|
|00000b40| 70 3e 5d 20 5b 2d 76 5d | 20 5b 2d 6e 5d 20 5b 2d |p>] [-v]| [-n] [-|
|00000b50| 68 5d 20 5b 2d 56 5d 20 | 5b 2d 50 5d 20 5b 2d 65 |h] [-V] |[-P] [-e|
|00000b60| 20 65 78 70 72 5d 5c 6e | 22 0a 22 5c 74 5b 2d 2d | expr]\n|"."\t[--|
|00000b70| 73 70 79 20 3c 69 66 3e | 5d 5c 6e 5c 6e 22 0a 22 |spy <if>|]\n\n"."|
|00000b80| 20 20 2d 69 5c 74 73 70 | 65 63 69 66 79 20 77 68 | -i\tsp|ecify wh|
|00000b90| 69 63 68 20 69 6e 74 65 | 72 66 61 63 65 20 74 6f |ich inte|rface to|
|00000ba0| 20 6c 69 73 74 65 6e 20 | 6f 6e 5c 6e 22 0a 22 20 | listen |on\n"." |
|00000bb0| 20 2d 70 5c 74 77 65 62 | 20 69 6e 74 65 72 66 61 | -p\tweb| interfa|
|00000bc0| 63 65 20 70 6f 72 74 20 | 28 64 65 66 61 75 6c 74 |ce port |(default|
|00000bd0| 3a 20 25 64 29 5c 6e 22 | 0a 22 20 20 2d 62 5c 74 |: %d)\n"|." -b\t|
|00000be0| 77 68 69 63 68 20 6c 6f | 63 61 6c 20 49 50 20 74 |which lo|cal IP t|
|00000bf0| 6f 20 62 69 6e 64 20 74 | 68 65 20 77 65 62 20 69 |o bind t|he web i|
|00000c00| 6e 74 65 72 66 61 63 65 | 20 74 6f 20 28 64 65 66 |nterface| to (def|
|00000c10| 61 75 6c 74 3a 20 61 6c | 6c 29 5c 6e 22 0a 22 20 |ault: al|l)\n"." |
|00000c20| 20 2d 64 5c 74 64 61 74 | 61 62 61 73 65 20 73 74 | -d\tdat|abase st|
|00000c30| 6f 72 61 67 65 20 64 69 | 72 65 63 74 6f 72 79 20 |orage di|rectory |
|00000c40| 28 64 65 66 61 75 6c 74 | 3a 20 77 6f 72 6b 69 6e |(default|: workin|
|00000c50| 67 20 64 69 72 65 63 74 | 6f 72 79 29 5c 6e 22 0a |g direct|ory)\n".|
|00000c60| 22 20 20 2d 6c 5c 74 6c | 6f 63 61 6c 20 6e 65 74 |" -l\tl|ocal net|
|00000c70| 77 6f 72 6b 20 72 61 6e | 67 65 20 66 6f 72 20 63 |work ran|ge for c|
|00000c80| 6f 72 72 65 63 74 20 53 | 4e 41 54 20 61 63 63 6f |orrect S|NAT acco|
|00000c90| 75 6e 74 69 6e 67 20 28 | 4c 69 6e 75 78 20 32 2e |unting (|Linux 2.|
|00000ca0| 34 2e 78 29 5c 6e 22 0a | 22 20 20 2d 66 5c 74 66 |4.x)\n".|" -f\tf|
|00000cb0| 6f 72 63 65 20 6c 6f 63 | 61 6c 20 69 70 20 74 6f |orce loc|al ip to|
|00000cc0| 20 3c 69 70 3e 20 28 67 | 72 65 61 74 20 66 6f 72 | <ip> (g|reat for|
|00000cd0| 20 6d 75 6c 74 69 68 6f | 6d 65 64 20 73 65 72 76 | multiho|med serv|
|00000ce0| 65 72 73 29 5c 6e 22 0a | 22 20 20 2d 76 5c 74 76 |ers)\n".|" -v\tv|
|00000cf0| 65 72 62 6f 73 65 20 6d | 6f 64 65 20 2d 20 70 61 |erbose m|ode - pa|
|00000d00| 63 6b 65 74 20 64 75 6d | 70 73 20 61 6e 64 20 6d |cket dum|ps and m|
|00000d10| 6f 72 65 5c 6e 22 0a 22 | 20 20 2d 6e 5c 74 64 6f |ore\n"."| -n\tdo|
|00000d20| 6e 27 74 20 72 65 73 6f | 6c 76 65 20 49 50 73 20 |n't reso|lve IPs |
|00000d30| 74 6f 20 68 6f 73 74 6e | 61 6d 65 73 5c 6e 22 0a |to hostn|ames\n".|
|00000d40| 22 20 20 2d 68 5c 74 68 | 65 6c 70 20 28 77 68 61 |" -h\th|elp (wha|
|00000d50| 74 20 79 6f 75 27 72 65 | 20 6c 6f 6f 6b 69 6e 67 |t you're| looking|
|00000d60| 20 61 74 20 6e 6f 77 29 | 5c 6e 22 0a 22 20 20 2d | at now)|\n"." -|
|00000d70| 56 5c 74 76 65 72 73 69 | 6f 6e 20 69 6e 66 6f 72 |V\tversi|on infor|
|00000d80| 6d 61 74 69 6f 6e 5c 6e | 22 0a 22 20 20 2d 50 5c |mation\n|"." -P\|
|00000d90| 74 74 75 72 6e 20 6f 66 | 66 20 70 72 6f 6d 69 73 |tturn of|f promis|
|00000da0| 63 75 6f 75 73 20 6d 6f | 64 65 5c 6e 22 0a 22 20 |cuous mo|de\n"." |
|00000db0| 20 2d 65 5c 74 73 70 65 | 63 69 66 79 20 65 78 70 | -e\tspe|cify exp|
|00000dc0| 72 65 73 73 69 6f 6e 20 | 74 6f 20 66 69 6c 74 65 |ression |to filte|
|00000dd0| 72 20 70 61 63 6b 65 74 | 73 5c 6e 5c 6e 22 0a 22 |r packet|s\n\n"."|
|00000de0| 20 20 2d 2d 73 70 79 5c | 74 6c 6f 67 20 48 54 54 | --spy\|tlog HTT|
|00000df0| 50 20 72 65 71 75 65 73 | 74 73 20 73 65 65 6e 20 |P reques|ts seen |
|00000e00| 6f 6e 20 73 70 65 63 69 | 66 69 65 64 20 69 6e 74 |on speci|fied int|
|00000e10| 65 72 66 61 63 65 5c 6e | 5c 6e 22 2c 0a 09 09 09 |erface\n|\n",....|
|00000e20| 09 61 72 67 76 5b 30 5d | 2c 20 77 65 62 70 6f 72 |.argv[0]|, webpor|
|00000e30| 74 29 3b 0a 0a 09 09 09 | 72 65 74 75 72 6e 20 45 |t);.....|return E|
|00000e40| 58 49 54 5f 53 55 43 43 | 45 53 53 3b 0a 09 09 7d |XIT_SUCC|ESS;...}|
|00000e50| 0a 09 09 65 6c 73 65 20 | 69 66 20 28 73 74 72 63 |...else |if (strc|
|00000e60| 6d 70 28 61 72 67 76 5b | 69 5d 2c 20 22 2d 76 22 |mp(argv[|i], "-v"|
|00000e70| 29 20 3d 3d 20 30 29 20 | 76 65 72 62 6f 73 65 20 |) == 0) |verbose |
|00000e80| 3d 20 31 3b 0a 09 09 65 | 6c 73 65 20 69 66 20 28 |= 1;...e|lse if (|
|00000e90| 73 74 72 63 6d 70 28 61 | 72 67 76 5b 69 5d 2c 20 |strcmp(a|rgv[i], |
|00000ea0| 22 2d 6e 22 29 20 3d 3d | 20 30 29 20 77 61 6e 74 |"-n") ==| 0) want|
|00000eb0| 5f 72 65 73 6f 6c 76 65 | 20 3d 20 4f 46 46 3b 0a |_resolve| = OFF;.|
|00000ec0| 09 09 65 6c 73 65 20 69 | 66 20 28 73 74 72 63 6d |..else i|f (strcm|
|00000ed0| 70 28 61 72 67 76 5b 69 | 5d 2c 20 22 2d 50 22 29 |p(argv[i|], "-P")|
|00000ee0| 20 3d 3d 20 30 29 20 70 | 72 6f 6d 69 73 63 20 3d | == 0) p|romisc =|
|00000ef0| 20 30 3b 0a 09 09 65 6c | 73 65 20 69 66 20 28 73 | 0;...el|se if (s|
|00000f00| 74 72 63 6d 70 28 61 72 | 67 76 5b 69 5d 2c 20 22 |trcmp(ar|gv[i], "|
|00000f10| 2d 2d 73 70 79 22 29 20 | 3d 3d 20 30 29 0a 09 09 |--spy") |== 0)...|
|00000f20| 7b 0a 09 09 09 77 61 6e | 74 5f 73 70 79 20 3d 20 |{....wan|t_spy = |
|00000f30| 31 3b 0a 09 09 09 69 2b | 2b 3b 0a 09 09 09 69 66 |1;....i+|+;....if|
|00000f40| 20 28 28 61 72 67 63 20 | 3c 20 69 2b 31 29 20 7c | ((argc |< i+1) ||
|00000f50| 7c 20 28 61 72 67 76 5b | 69 5d 5b 30 5d 20 3d 3d || (argv[|i][0] ==|
|00000f60| 20 27 2d 27 29 29 0a 09 | 09 09 7b 0a 09 09 09 09 | '-'))..|..{.....|
|00000f70| 70 72 69 6e 74 66 28 22 | 49 6e 74 65 72 66 61 63 |printf("|Interfac|
|00000f80| 65 20 6e 6f 74 20 73 70 | 65 63 69 66 69 65 64 21 |e not sp|ecified!|
|00000f90| 5c 6e 5c 6e 22 29 3b 0a | 09 09 09 09 72 65 74 75 |\n\n");.|....retu|
|00000fa0| 72 6e 20 45 58 49 54 5f | 46 41 49 4c 3b 0a 09 09 |rn EXIT_|FAIL;...|
|00000fb0| 09 7d 0a 09 09 09 73 70 | 79 64 65 76 20 3d 20 61 |.}....sp|ydev = a|
|00000fc0| 72 67 76 5b 69 5d 3b 0a | 09 09 7d 0a 09 09 65 6c |rgv[i];.|..}...el|
|00000fd0| 73 65 20 69 66 20 28 73 | 74 72 63 6d 70 28 61 72 |se if (s|trcmp(ar|
|00000fe0| 67 76 5b 69 5d 2c 20 22 | 2d 70 22 29 20 3d 3d 20 |gv[i], "|-p") == |
|00000ff0| 30 29 0a 09 09 7b 0a 09 | 09 09 69 2b 2b 3b 0a 09 |0)...{..|..i++;..|
|00001000| 09 09 69 66 20 28 28 61 | 72 67 63 20 3c 20 69 2b |..if ((a|rgc < i+|
|00001010| 31 29 20 7c 7c 20 28 61 | 72 67 76 5b 69 5d 5b 30 |1) || (a|rgv[i][0|
|00001020| 5d 20 3d 3d 20 27 2d 27 | 29 29 0a 09 09 09 7b 0a |] == '-'|))....{.|
|00001030| 09 09 09 09 70 72 69 6e | 74 66 28 22 50 6f 72 74 |....prin|tf("Port|
|00001040| 20 6e 6f 74 20 73 70 65 | 63 69 66 69 65 64 21 5c | not spe|cified!\|
|00001050| 6e 5c 6e 22 29 3b 0a 09 | 09 09 09 72 65 74 75 72 |n\n");..|...retur|
|00001060| 6e 20 45 58 49 54 5f 46 | 41 49 4c 3b 0a 09 09 09 |n EXIT_F|AIL;....|
|00001070| 7d 0a 09 09 09 77 65 62 | 70 6f 72 74 20 3d 20 61 |}....web|port = a|
|00001080| 74 6f 69 28 61 72 67 76 | 5b 69 5d 29 3b 0a 09 09 |toi(argv|[i]);...|
|00001090| 7d 0a 09 09 65 6c 73 65 | 20 69 66 20 28 73 74 72 |}...else| if (str|
|000010a0| 63 6d 70 28 61 72 67 76 | 5b 69 5d 2c 20 22 2d 62 |cmp(argv|[i], "-b|
|000010b0| 22 29 20 3d 3d 20 30 29 | 0a 09 09 7b 0a 09 09 09 |") == 0)|...{....|
|000010c0| 69 6e 74 20 69 31 2c 69 | 32 2c 69 33 2c 69 34 3b |int i1,i|2,i3,i4;|
|000010d0| 0a 0a 09 09 09 69 2b 2b | 3b 0a 09 09 09 69 66 20 |.....i++|;....if |
|000010e0| 28 28 61 72 67 63 20 3c | 20 69 2b 31 29 20 7c 7c |((argc <| i+1) |||
|000010f0| 20 28 61 72 67 76 5b 69 | 5d 5b 30 5d 20 3d 3d 20 | (argv[i|][0] == |
|00001100| 27 2d 27 29 29 0a 09 09 | 09 7b 0a 09 09 09 09 70 |'-'))...|.{.....p|
|00001110| 72 69 6e 74 66 28 22 42 | 69 6e 64 20 49 50 20 6e |rintf("B|ind IP n|
|00001120| 6f 74 20 73 70 65 63 69 | 66 69 65 64 21 5c 6e 5c |ot speci|fied!\n\|
|00001130| 6e 22 29 3b 0a 09 09 09 | 09 72 65 74 75 72 6e 20 |n");....|.return |
|00001140| 45 58 49 54 5f 46 41 49 | 4c 3b 0a 09 09 09 7d 0a |EXIT_FAI|L;....}.|
|00001150| 09 09 09 73 73 63 61 6e | 66 28 61 72 67 76 5b 69 |...sscan|f(argv[i|
|00001160| 5d 2c 20 22 25 64 2e 25 | 64 2e 25 64 2e 25 64 22 |], "%d.%|d.%d.%d"|
|00001170| 2c 0a 09 09 09 09 26 69 | 31 2c 20 26 69 32 2c 20 |,.....&i|1, &i2, |
|00001180| 26 69 33 2c 20 26 69 34 | 29 3b 0a 0a 09 09 09 77 |&i3, &i4|);.....w|
|00001190| 65 62 69 70 20 3d 20 69 | 70 5f 66 72 6f 6d 5f 71 |ebip = i|p_from_q|
|000011a0| 75 61 64 28 69 31 2c 69 | 32 2c 69 33 2c 69 34 29 |uad(i1,i|2,i3,i4)|
|000011b0| 3b 0a 0a 09 09 09 70 72 | 69 6e 74 66 28 22 42 69 |;.....pr|intf("Bi|
|000011c0| 6e 64 69 6e 67 20 77 65 | 62 73 65 72 76 65 72 20 |nding we|bserver |
|000011d0| 74 6f 20 25 64 2e 25 64 | 2e 25 64 2e 25 64 5c 6e |to %d.%d|.%d.%d\n|
|000011e0| 22 2c 0a 09 09 09 09 69 | 31 2c 69 32 2c 69 33 2c |",.....i|1,i2,i3,|
|000011f0| 69 34 29 3b 0a 09 09 7d | 0a 09 09 65 6c 73 65 20 |i4);...}|...else |
|00001200| 69 66 20 28 73 74 72 63 | 6d 70 28 61 72 67 76 5b |if (strc|mp(argv[|
|00001210| 69 5d 2c 20 22 2d 69 22 | 29 20 3d 3d 20 30 29 0a |i], "-i"|) == 0).|
|00001220| 09 09 7b 0a 09 09 09 69 | 2b 2b 3b 0a 09 09 09 69 |..{....i|++;....i|
|00001230| 66 20 28 28 61 72 67 63 | 20 3c 20 69 2b 31 29 20 |f ((argc| < i+1) |
|00001240| 7c 7c 20 28 61 72 67 76 | 5b 69 5d 5b 30 5d 20 3d ||| (argv|[i][0] =|
|00001250| 3d 20 27 2d 27 29 29 0a | 09 09 09 7b 0a 09 09 09 |= '-')).|...{....|
|00001260| 09 70 72 69 6e 74 66 28 | 22 49 6e 74 65 72 66 61 |.printf(|"Interfa|
|00001270| 63 65 20 6e 6f 74 20 73 | 70 65 63 69 66 69 65 64 |ce not s|pecified|
|00001280| 21 5c 6e 5c 6e 22 29 3b | 0a 09 09 09 09 72 65 74 |!\n\n");|.....ret|
|00001290| 75 72 6e 20 45 58 49 54 | 5f 46 41 49 4c 3b 0a 09 |urn EXIT|_FAIL;..|
|000012a0| 09 09 7d 0a 09 09 09 61 | 63 63 74 64 65 76 20 3d |..}....a|cctdev =|
|000012b0| 20 61 72 67 76 5b 69 5d | 3b 0a 09 09 7d 0a 09 09 | argv[i]|;...}...|
|000012c0| 65 6c 73 65 20 69 66 20 | 28 73 74 72 63 6d 70 28 |else if |(strcmp(|
|000012d0| 61 72 67 76 5b 69 5d 2c | 20 22 2d 64 22 29 20 3d |argv[i],| "-d") =|
|000012e0| 3d 20 30 29 0a 09 09 7b | 0a 09 09 09 69 2b 2b 3b |= 0)...{|....i++;|
|000012f0| 0a 09 09 09 69 66 20 28 | 28 61 72 67 63 20 3c 20 |....if (|(argc < |
|00001300| 69 2b 31 29 20 7c 7c 20 | 28 61 72 67 76 5b 69 5d |i+1) || |(argv[i]|
|00001310| 5b 30 5d 20 3d 3d 20 27 | 2d 27 29 29 0a 09 09 09 |[0] == '|-'))....|
|00001320| 7b 0a 09 09 09 09 70 72 | 69 6e 74 66 28 22 44 69 |{.....pr|intf("Di|
|00001330| 72 65 63 74 6f 72 79 20 | 6e 6f 74 20 73 70 65 63 |rectory |not spec|
|00001340| 69 66 69 65 64 21 5c 6e | 5c 6e 22 29 3b 0a 09 09 |ified!\n|\n");...|
|00001350| 09 09 72 65 74 75 72 6e | 20 45 58 49 54 5f 46 41 |..return| EXIT_FA|
|00001360| 49 4c 3b 0a 09 09 09 7d | 0a 09 09 09 66 70 72 65 |IL;....}|....fpre|
|00001370| 66 69 78 20 3d 20 62 75 | 69 6c 64 5f 73 74 72 28 |fix = bu|ild_str(|
|00001380| 22 25 73 25 73 22 2c 20 | 61 72 67 76 5b 69 5d 2c |"%s%s", |argv[i],|
|00001390| 0a 09 09 09 09 61 72 67 | 76 5b 69 5d 5b 73 74 72 |.....arg|v[i][str|
|000013a0| 6c 65 6e 28 61 72 67 76 | 5b 69 5d 29 2d 31 5d 20 |len(argv|[i])-1] |
|000013b0| 3d 3d 20 27 2f 27 3f 22 | 22 3a 22 2f 22 29 3b 0a |== '/'?"|":"/");.|
|000013c0| 09 09 7d 0a 09 09 65 6c | 73 65 20 69 66 20 28 28 |..}...el|se if ((|
|000013d0| 73 74 72 63 6d 70 28 61 | 72 67 76 5b 69 5d 2c 20 |strcmp(a|rgv[i], |
|000013e0| 22 2d 56 22 29 20 3d 3d | 20 30 29 20 7c 7c 0a 09 |"-V") ==| 0) ||..|
|000013f0| 09 09 28 73 74 72 63 6d | 70 28 61 72 67 76 5b 69 |..(strcm|p(argv[i|
|00001400| 5d 2c 20 22 2d 2d 76 65 | 72 73 69 6f 6e 22 29 20 |], "--ve|rsion") |
|00001410| 3d 3d 20 30 29 29 0a 09 | 09 7b 0a 09 09 09 70 72 |== 0))..|.{....pr|
|00001420| 69 6e 74 66 28 43 4f 50 | 59 52 49 47 48 54 20 22 |intf(COP|YRIGHT "|
|00001430| 5c 6e 22 20 48 4f 4d 45 | 50 41 47 45 20 22 5c 6e |\n" HOME|PAGE "\n|
|00001440| 5c 6e 22 0a 22 54 68 69 | 73 20 70 72 6f 67 72 61 |\n"."Thi|s progra|
|00001450| 6d 20 69 73 20 66 72 65 | 65 20 73 6f 66 74 77 61 |m is fre|e softwa|
|00001460| 72 65 3b 20 79 6f 75 20 | 63 61 6e 20 72 65 64 69 |re; you |can redi|
|00001470| 73 74 72 69 62 75 74 65 | 20 69 74 20 61 6e 64 2f |stribute| it and/|
|00001480| 6f 72 20 6d 6f 64 69 66 | 79 5c 6e 22 0a 22 69 74 |or modif|y\n"."it|
|00001490| 20 75 6e 64 65 72 20 74 | 68 65 20 74 65 72 6d 73 | under t|he terms|
|000014a0| 20 6f 66 20 74 68 65 20 | 47 4e 55 20 47 65 6e 65 | of the |GNU Gene|
|000014b0| 72 61 6c 20 50 75 62 6c | 69 63 20 4c 69 63 65 6e |ral Publ|ic Licen|
|000014c0| 73 65 20 61 73 20 70 75 | 62 6c 69 73 68 65 64 20 |se as pu|blished |
|000014d0| 62 79 5c 6e 22 0a 22 74 | 68 65 20 46 72 65 65 20 |by\n"."t|he Free |
|000014e0| 53 6f 66 74 77 61 72 65 | 20 46 6f 75 6e 64 61 74 |Software| Foundat|
|000014f0| 69 6f 6e 3b 20 65 69 74 | 68 65 72 20 76 65 72 73 |ion; eit|her vers|
|00001500| 69 6f 6e 20 32 20 6f 66 | 20 74 68 65 20 4c 69 63 |ion 2 of| the Lic|
|00001510| 65 6e 73 65 2c 20 6f 72 | 5c 6e 22 0a 22 28 61 74 |ense, or|\n"."(at|
|00001520| 20 79 6f 75 72 20 6f 70 | 74 69 6f 6e 29 20 61 6e | your op|tion) an|
|00001530| 79 20 6c 61 74 65 72 20 | 76 65 72 73 69 6f 6e 2e |y later |version.|
|00001540| 5c 6e 5c 6e 22 0a 0a 22 | 54 68 69 73 20 70 72 6f |\n\n".."|This pro|
|00001550| 67 72 61 6d 20 69 73 20 | 64 69 73 74 72 69 62 75 |gram is |distribu|
|00001560| 74 65 64 20 69 6e 20 74 | 68 65 20 68 6f 70 65 20 |ted in t|he hope |
|00001570| 74 68 61 74 20 69 74 20 | 77 69 6c 6c 20 62 65 20 |that it |will be |
|00001580| 75 73 65 66 75 6c 2c 5c | 6e 22 0a 22 62 75 74 20 |useful,\|n"."but |
|00001590| 57 49 54 48 4f 55 54 20 | 41 4e 59 20 57 41 52 52 |WITHOUT |ANY WARR|
|000015a0| 41 4e 54 59 3b 20 77 69 | 74 68 6f 75 74 20 65 76 |ANTY; wi|thout ev|
|000015b0| 65 6e 20 74 68 65 20 69 | 6d 70 6c 69 65 64 20 77 |en the i|mplied w|
|000015c0| 61 72 72 61 6e 74 79 20 | 6f 66 5c 6e 22 0a 22 4d |arranty |of\n"."M|
|000015d0| 45 52 43 48 41 4e 54 41 | 42 49 4c 49 54 59 20 6f |ERCHANTA|BILITY o|
|000015e0| 72 20 46 49 54 4e 45 53 | 53 20 46 4f 52 20 41 20 |r FITNES|S FOR A |
|000015f0| 50 41 52 54 49 43 55 4c | 41 52 20 50 55 52 50 4f |PARTICUL|AR PURPO|
|00001600| 53 45 2e 20 20 53 65 65 | 20 74 68 65 5c 6e 22 0a |SE. See| the\n".|
|00001610| 22 47 4e 55 20 47 65 6e | 65 72 61 6c 20 50 75 62 |"GNU Gen|eral Pub|
|00001620| 6c 69 63 20 4c 69 63 65 | 6e 73 65 20 66 6f 72 20 |lic Lice|nse for |
|00001630| 6d 6f 72 65 20 64 65 74 | 61 69 6c 73 2e 5c 6e 5c |more det|ails.\n\|
|00001640| 6e 22 0a 0a 22 59 6f 75 | 20 73 68 6f 75 6c 64 20 |n".."You| should |
|00001650| 68 61 76 65 20 72 65 63 | 65 69 76 65 64 20 61 20 |have rec|eived a |
|00001660| 63 6f 70 79 20 6f 66 20 | 74 68 65 20 47 4e 55 20 |copy of |the GNU |
|00001670| 47 65 6e 65 72 61 6c 20 | 50 75 62 6c 69 63 20 4c |General |Public L|
|00001680| 69 63 65 6e 73 65 5c 6e | 22 0a 22 61 6c 6f 6e 67 |icense\n|"."along|
|00001690| 20 77 69 74 68 20 74 68 | 69 73 20 70 72 6f 67 72 | with th|is progr|
|000016a0| 61 6d 2e 20 49 66 20 6e | 6f 74 2c 20 77 72 69 74 |am. If n|ot, writ|
|000016b0| 65 20 74 6f 20 74 68 65 | 20 46 72 65 65 20 53 6f |e to the| Free So|
|000016c0| 66 74 77 61 72 65 5c 6e | 22 0a 22 46 6f 75 6e 64 |ftware\n|"."Found|
|000016d0| 61 74 69 6f 6e 2c 20 36 | 37 35 20 4d 61 73 73 20 |ation, 6|75 Mass |
|000016e0| 41 76 65 2c 20 43 61 6d | 62 72 69 64 67 65 2c 20 |Ave, Cam|bridge, |
|000016f0| 4d 41 20 30 32 31 33 39 | 2c 20 55 53 41 2e 5c 6e |MA 02139|, USA.\n|
|00001700| 5c 6e 22 0a 09 09 09 29 | 3b 0a 09 09 09 72 65 74 |\n"....)|;....ret|
|00001710| 75 72 6e 20 45 58 49 54 | 5f 53 55 43 43 45 53 53 |urn EXIT|_SUCCESS|
|00001720| 3b 0a 09 09 7d 0a 09 09 | 65 6c 73 65 20 69 66 20 |;...}...|else if |
|00001730| 28 73 74 72 63 6d 70 28 | 61 72 67 76 5b 69 5d 2c |(strcmp(|argv[i],|
|00001740| 20 22 2d 6c 22 29 20 3d | 3d 20 30 29 0a 09 09 7b | "-l") =|= 0)...{|
|00001750| 0a 09 09 09 69 6e 74 20 | 69 31 2c 69 32 2c 69 33 |....int |i1,i2,i3|
|00001760| 2c 69 34 2c 20 6d 31 2c | 6d 32 2c 6d 33 2c 6d 34 |,i4, m1,|m2,m3,m4|
|00001770| 3b 0a 09 09 09 0a 09 09 | 09 69 2b 2b 3b 0a 09 09 |;.......|.i++;...|
|00001780| 09 69 66 20 28 28 61 72 | 67 63 20 3c 20 69 2b 31 |.if ((ar|gc < i+1|
|00001790| 29 20 7c 7c 20 28 61 72 | 67 76 5b 69 5d 5b 30 5d |) || (ar|gv[i][0]|
|000017a0| 20 3d 3d 20 27 2d 27 29 | 29 0a 09 09 09 7b 0a 09 | == '-')|)....{..|
|000017b0| 09 09 09 70 72 69 6e 74 | 66 28 22 4c 41 4e 20 73 |...print|f("LAN s|
|000017c0| 70 61 63 65 20 6e 6f 74 | 20 73 70 65 63 69 66 69 |pace not| specifi|
|000017d0| 65 64 21 5c 6e 5c 6e 22 | 29 3b 0a 09 09 09 09 72 |ed!\n\n"|);.....r|
|000017e0| 65 74 75 72 6e 20 45 58 | 49 54 5f 46 41 49 4c 3b |eturn EX|IT_FAIL;|
|000017f0| 0a 09 09 09 7d 0a 09 09 | 09 73 73 63 61 6e 66 28 |....}...|.sscanf(|
|00001800| 61 72 67 76 5b 69 5d 2c | 20 22 25 64 2e 25 64 2e |argv[i],| "%d.%d.|
|00001810| 25 64 2e 25 64 2f 25 64 | 2e 25 64 2e 25 64 2e 25 |%d.%d/%d|.%d.%d.%|
|00001820| 64 22 2c 0a 09 09 09 09 | 26 69 31 2c 20 26 69 32 |d",.....|&i1, &i2|
|00001830| 2c 20 26 69 33 2c 20 26 | 69 34 2c 0a 09 09 09 09 |, &i3, &|i4,.....|
|00001840| 26 6d 31 2c 20 26 6d 32 | 2c 20 26 6d 33 2c 20 26 |&m1, &m2|, &m3, &|
|00001850| 6d 34 29 3b 0a 0a 09 09 | 09 6c 61 6e 5f 69 70 20 |m4);....|.lan_ip |
|00001860| 3d 20 69 70 5f 66 72 6f | 6d 5f 71 75 61 64 28 69 |= ip_fro|m_quad(i|
|00001870| 31 2c 69 32 2c 69 33 2c | 69 34 29 3b 0a 09 09 09 |1,i2,i3,|i4);....|
|00001880| 6c 61 6e 5f 6d 61 73 6b | 20 3d 20 69 70 5f 66 72 |lan_mask| = ip_fr|
|00001890| 6f 6d 5f 71 75 61 64 28 | 6d 31 2c 6d 32 2c 6d 33 |om_quad(|m1,m2,m3|
|000018a0| 2c 6d 34 29 3b 0a 0a 09 | 09 09 70 72 69 6e 74 66 |,m4);...|..printf|
|000018b0| 28 22 4c 6f 63 61 6c 20 | 4c 41 4e 20 69 73 20 25 |("Local |LAN is %|
|000018c0| 64 2e 25 64 2e 25 64 2e | 25 64 2f 25 64 2e 25 64 |d.%d.%d.|%d/%d.%d|
|000018d0| 2e 25 64 2e 25 64 5c 6e | 22 2c 0a 09 09 09 09 69 |.%d.%d\n|",.....i|
|000018e0| 31 2c 69 32 2c 69 33 2c | 69 34 2c 20 6d 31 2c 6d |1,i2,i3,|i4, m1,m|
|000018f0| 32 2c 6d 33 2c 6d 34 29 | 3b 0a 09 09 7d 0a 09 09 |2,m3,m4)|;...}...|
|00001900| 65 6c 73 65 20 69 66 20 | 28 73 74 72 63 6d 70 28 |else if |(strcmp(|
|00001910| 61 72 67 76 5b 69 5d 2c | 20 22 2d 66 22 29 20 3d |argv[i],| "-f") =|
|00001920| 3d 20 30 29 0a 09 09 7b | 0a 09 09 09 69 6e 74 20 |= 0)...{|....int |
|00001930| 69 31 2c 69 32 2c 69 33 | 2c 69 34 3b 0a 09 09 09 |i1,i2,i3|,i4;....|
|00001940| 0a 09 09 09 69 2b 2b 3b | 0a 09 09 09 69 66 20 28 |....i++;|....if (|
|00001950| 28 61 72 67 63 20 3c 20 | 69 2b 31 29 20 7c 7c 20 |(argc < |i+1) || |
|00001960| 28 61 72 67 76 5b 69 5d | 5b 30 5d 20 3d 3d 20 27 |(argv[i]|[0] == '|
|00001970| 2d 27 29 29 0a 09 09 09 | 7b 0a 09 09 09 09 70 72 |-'))....|{.....pr|
|00001980| 69 6e 74 66 28 22 46 6f | 72 63 65 64 20 49 50 20 |intf("Fo|rced IP |
|00001990| 6e 6f 74 20 73 70 65 63 | 69 66 69 65 64 21 5c 6e |not spec|ified!\n|
|000019a0| 5c 6e 22 29 3b 0a 09 09 | 09 09 72 65 74 75 72 6e |\n");...|..return|
|000019b0| 20 45 58 49 54 5f 46 41 | 49 4c 3b 0a 09 09 09 7d | EXIT_FA|IL;....}|
|000019c0| 0a 09 09 09 73 73 63 61 | 6e 66 28 61 72 67 76 5b |....ssca|nf(argv[|
|000019d0| 69 5d 2c 20 22 25 64 2e | 25 64 2e 25 64 2e 25 64 |i], "%d.|%d.%d.%d|
|000019e0| 22 2c 0a 09 09 09 09 26 | 69 31 2c 20 26 69 32 2c |",.....&|i1, &i2,|
|000019f0| 20 26 69 33 2c 20 26 69 | 34 29 3b 0a 0a 09 09 09 | &i3, &i|4);.....|
|00001a00| 6c 6f 63 61 6c 5f 69 70 | 20 3d 20 69 70 5f 66 72 |local_ip| = ip_fr|
|00001a10| 6f 6d 5f 71 75 61 64 28 | 69 31 2c 69 32 2c 69 33 |om_quad(|i1,i2,i3|
|00001a20| 2c 69 34 29 3b 0a 0a 09 | 09 09 70 72 69 6e 74 66 |,i4);...|..printf|
|00001a30| 28 22 46 6f 72 63 65 64 | 20 49 50 20 74 6f 20 25 |("Forced| IP to %|
|00001a40| 64 2e 25 64 2e 25 64 2e | 25 64 5c 6e 22 2c 0a 09 |d.%d.%d.|%d\n",..|
|00001a50| 09 09 09 69 31 2c 69 32 | 2c 69 33 2c 69 34 29 3b |...i1,i2|,i3,i4);|
|00001a60| 0a 09 09 7d 0a 09 09 65 | 6c 73 65 20 69 66 20 28 |...}...e|lse if (|
|00001a70| 73 74 72 63 6d 70 28 61 | 72 67 76 5b 69 5d 2c 20 |strcmp(a|rgv[i], |
|00001a80| 22 2d 65 22 29 20 3d 3d | 20 30 29 0a 09 09 7b 0a |"-e") ==| 0)...{.|
|00001a90| 09 09 09 69 2b 2b 3b 0a | 09 09 09 69 66 20 28 28 |...i++;.|...if ((|
|00001aa0| 61 72 67 63 20 3c 20 69 | 2b 31 29 20 7c 7c 20 28 |argc < i|+1) || (|
|00001ab0| 61 72 67 76 5b 69 5d 5b | 30 5d 20 3d 3d 20 27 2d |argv[i][|0] == '-|
|00001ac0| 27 29 29 0a 09 09 09 7b | 0a 09 09 09 09 70 72 69 |'))....{|.....pri|
|00001ad0| 6e 74 66 28 22 45 78 70 | 72 65 73 73 69 6f 6e 20 |ntf("Exp|ression |
|00001ae0| 6e 6f 74 20 73 70 65 63 | 69 66 69 65 64 21 5c 6e |not spec|ified!\n|
|00001af0| 5c 6e 22 29 3b 0a 09 09 | 09 09 72 65 74 75 72 6e |\n");...|..return|
|00001b00| 20 45 58 49 54 5f 46 41 | 49 4c 3b 0a 09 09 09 7d | EXIT_FA|IL;....}|
|00001b10| 0a 09 09 09 61 63 63 74 | 65 78 70 72 20 3d 20 61 |....acct|expr = a|
|00001b20| 72 67 76 5b 69 5d 3b 0a | 09 09 7d 0a 09 09 65 6c |rgv[i];.|..}...el|
|00001b30| 73 65 20 7b 0a 09 09 09 | 70 72 69 6e 74 66 28 22 |se {....|printf("|
|00001b40| 49 6e 76 61 6c 69 64 20 | 61 72 67 75 6d 65 6e 74 |Invalid |argument|
|00001b50| 3a 20 25 73 5c 6e 22 2c | 20 61 72 67 76 5b 69 5d |: %s\n",| argv[i]|
|00001b60| 29 3b 0a 09 09 09 72 65 | 74 75 72 6e 20 45 58 49 |);....re|turn EXI|
|00001b70| 54 5f 46 41 49 4c 3b 0a | 09 09 7d 0a 09 7d 0a 0a |T_FAIL;.|..}..}..|
|00001b80| 09 69 66 20 28 21 61 63 | 63 74 64 65 76 29 0a 09 |.if (!ac|ctdev)..|
|00001b90| 7b 0a 09 09 61 63 63 74 | 64 65 76 20 3d 20 70 63 |{...acct|dev = pc|
|00001ba0| 61 70 5f 6c 6f 6f 6b 75 | 70 64 65 76 28 65 72 72 |ap_looku|pdev(err|
|00001bb0| 29 3b 0a 09 09 69 66 20 | 28 21 61 63 63 74 64 65 |);...if |(!acctde|
|00001bc0| 76 29 0a 09 09 7b 0a 09 | 09 09 70 72 69 6e 74 66 |v)...{..|..printf|
|00001bd0| 28 22 45 72 72 6f 72 3a | 20 70 63 61 70 5f 6c 6f |("Error:| pcap_lo|
|00001be0| 6f 6b 75 70 64 65 76 28 | 29 3a 20 25 73 5c 6e 22 |okupdev(|): %s\n"|
|00001bf0| 2c 20 65 72 72 29 3b 0a | 09 09 09 72 65 74 75 72 |, err);.|...retur|
|00001c00| 6e 20 45 58 49 54 5f 46 | 41 49 4c 3b 0a 09 09 7d |n EXIT_F|AIL;...}|
|00001c10| 0a 09 7d 0a 0a 09 2f 2a | 20 64 61 74 61 62 61 73 |..}.../*| databas|
|00001c20| 65 20 66 69 6c 65 73 2c | 20 61 63 63 6f 75 6e 74 |e files,| account|
|00001c30| 69 6e 67 20 66 6f 72 20 | 74 68 65 20 73 70 65 63 |ing for |the spec|
|00001c40| 69 66 69 65 64 20 73 74 | 6f 72 61 67 65 20 64 69 |ified st|orage di|
|00001c50| 72 65 63 74 6f 72 79 20 | 2a 2f 0a 09 69 66 20 28 |rectory |*/..if (|
|00001c60| 66 70 72 65 66 69 78 20 | 3d 3d 20 4e 55 4c 4c 29 |fprefix |== NULL)|
|00001c70| 20 66 70 72 65 66 69 78 | 3d 22 22 3b 0a 09 64 62 | fprefix|="";..db|
|00001c80| 5f 66 69 6c 65 20 3d 20 | 62 75 69 6c 64 5f 73 74 |_file = |build_st|
|00001c90| 72 28 22 25 73 22 20 44 | 42 5f 46 49 4c 45 5f 4e |r("%s" D|B_FILE_N|
|00001ca0| 41 4d 45 2c 20 66 70 72 | 65 66 69 78 29 3b 0a 09 |AME, fpr|efix);..|
|00001cb0| 65 72 72 64 62 5f 66 69 | 6c 65 20 3d 20 62 75 69 |errdb_fi|le = bui|
|00001cc0| 6c 64 5f 73 74 72 28 22 | 25 73 22 20 45 52 52 44 |ld_str("|%s" ERRD|
|00001cd0| 42 5f 46 49 4c 45 5f 4e | 41 4d 45 2c 20 66 70 72 |B_FILE_N|AME, fpr|
|00001ce0| 65 66 69 78 29 3b 0a 09 | 64 61 79 6c 6f 67 5f 66 |efix);..|daylog_f|
|00001cf0| 69 6c 65 20 3d 20 62 75 | 69 6c 64 5f 73 74 72 28 |ile = bu|ild_str(|
|00001d00| 22 25 73 22 20 44 41 59 | 4c 4f 47 5f 46 49 4c 45 |"%s" DAY|LOG_FILE|
|00001d10| 5f 4e 41 4d 45 2c 20 66 | 70 72 65 66 69 78 29 3b |_NAME, f|prefix);|
|00001d20| 0a 0a 09 2f 2a 20 74 68 | 65 20 6f 6e 6c 79 20 77 |.../* th|e only w|
|00001d30| 61 79 20 6f 75 74 20 2a | 2f 0a 09 73 69 67 6e 61 |ay out *|/..signa|
|00001d40| 6c 28 53 49 47 54 45 52 | 4d 2c 20 74 65 72 6d 5f |l(SIGTER|M, term_|
|00001d50| 73 69 67 6e 61 6c 29 3b | 0a 09 73 69 67 6e 61 6c |signal);|..signal|
|00001d60| 28 53 49 47 49 4e 54 2c | 20 74 65 72 6d 5f 73 69 |(SIGINT,| term_si|
|00001d70| 67 6e 61 6c 29 3b 0a 0a | 09 2f 2a 20 66 69 72 65 |gnal);..|./* fire|
|00001d80| 20 75 70 20 74 68 72 65 | 61 64 73 20 2a 2f 0a 09 | up thre|ads */..|
|00001d90| 70 72 69 6e 74 66 28 22 | 46 69 72 69 6e 67 20 75 |printf("|Firing u|
|00001da0| 70 20 74 68 72 65 61 64 | 73 2e 2e 2e 5c 6e 22 29 |p thread|s...\n")|
|00001db0| 3b 20 66 66 6c 75 73 68 | 28 73 74 64 6f 75 74 29 |; fflush|(stdout)|
|00001dc0| 3b 0a 0a 09 69 66 20 28 | 70 74 68 72 65 61 64 5f |;...if (|pthread_|
|00001dd0| 6d 75 74 65 78 5f 69 6e | 69 74 28 26 67 72 61 70 |mutex_in|it(&grap|
|00001de0| 68 5f 6d 75 74 65 78 2c | 20 4e 55 4c 4c 29 20 3d |h_mutex,| NULL) =|
|00001df0| 3d 20 2d 31 29 0a 09 7b | 0a 09 09 70 72 69 6e 74 |= -1)..{|...print|
|00001e00| 66 28 22 45 72 72 6f 72 | 3a 20 63 6f 75 6c 64 20 |f("Error|: could |
|00001e10| 6e 6f 74 20 63 72 65 61 | 74 65 20 67 72 61 70 68 |not crea|te graph|
|00001e20| 20 6d 75 74 65 78 2e 5c | 6e 22 29 3b 0a 09 09 72 | mutex.\|n");...r|
|00001e30| 65 74 75 72 6e 20 45 58 | 49 54 5f 46 41 49 4c 3b |eturn EX|IT_FAIL;|
|00001e40| 0a 09 7d 0a 09 69 66 20 | 28 70 74 68 72 65 61 64 |..}..if |(pthread|
|00001e50| 5f 6d 75 74 65 78 5f 69 | 6e 69 74 28 26 64 62 5f |_mutex_i|nit(&db_|
|00001e60| 6d 75 74 65 78 2c 20 4e | 55 4c 4c 29 20 3d 3d 20 |mutex, N|ULL) == |
|00001e70| 2d 31 29 0a 09 7b 0a 09 | 09 70 72 69 6e 74 66 28 |-1)..{..|.printf(|
|00001e80| 22 45 72 72 6f 72 3a 20 | 63 6f 75 6c 64 20 6e 6f |"Error: |could no|
|00001e90| 74 20 63 72 65 61 74 65 | 20 64 62 20 6d 75 74 65 |t create| db mute|
|00001ea0| 78 2e 5c 6e 22 29 3b 0a | 09 09 72 65 74 75 72 6e |x.\n");.|..return|
|00001eb0| 20 45 58 49 54 5f 46 41 | 49 4c 3b 0a 09 7d 0a 09 | EXIT_FA|IL;..}..|
|00001ec0| 69 66 20 28 70 74 68 72 | 65 61 64 5f 63 72 65 61 |if (pthr|ead_crea|
|00001ed0| 74 65 28 26 61 63 63 74 | 5f 74 68 72 65 61 64 2c |te(&acct|_thread,|
|00001ee0| 20 4e 55 4c 4c 2c 20 28 | 76 6f 69 64 2a 29 26 61 | NULL, (|void*)&a|
|00001ef0| 63 63 74 5f 6d 61 69 6e | 2c 20 4e 55 4c 4c 29 20 |cct_main|, NULL) |
|00001f00| 3d 3d 20 2d 31 29 0a 09 | 7b 0a 09 09 70 72 69 6e |== -1)..|{...prin|
|00001f10| 74 66 28 22 45 72 72 6f | 72 3a 20 63 6f 75 6c 64 |tf("Erro|r: could|
|00001f20| 20 6e 6f 74 20 63 72 65 | 61 74 65 20 41 43 43 54 | not cre|ate ACCT|
|00001f30| 20 74 68 72 65 61 64 2e | 5c 6e 22 29 3b 0a 09 09 | thread.|\n");...|
|00001f40| 72 65 74 75 72 6e 20 45 | 58 49 54 5f 46 41 49 4c |return E|XIT_FAIL|
|00001f50| 3b 0a 09 7d 0a 09 69 66 | 20 28 70 74 68 72 65 61 |;..}..if| (pthrea|
|00001f60| 64 5f 63 72 65 61 74 65 | 28 26 64 6e 73 5f 74 68 |d_create|(&dns_th|
|00001f70| 72 65 61 64 2c 20 4e 55 | 4c 4c 2c 20 28 76 6f 69 |read, NU|LL, (voi|
|00001f80| 64 2a 29 26 64 6e 73 5f | 6d 61 69 6e 2c 20 4e 55 |d*)&dns_|main, NU|
|00001f90| 4c 4c 29 20 3d 3d 20 2d | 31 29 0a 09 7b 0a 09 09 |LL) == -|1)..{...|
|00001fa0| 70 72 69 6e 74 66 28 22 | 45 72 72 6f 72 3a 20 63 |printf("|Error: c|
|00001fb0| 6f 75 6c 64 20 6e 6f 74 | 20 63 72 65 61 74 65 20 |ould not| create |
|00001fc0| 44 4e 53 20 74 68 72 65 | 61 64 2e 5c 6e 22 29 3b |DNS thre|ad.\n");|
|00001fd0| 0a 09 09 72 65 74 75 72 | 6e 20 45 58 49 54 5f 46 |...retur|n EXIT_F|
|00001fe0| 41 49 4c 3b 0a 09 7d 0a | 09 69 66 20 28 70 74 68 |AIL;..}.|.if (pth|
|00001ff0| 72 65 61 64 5f 63 72 65 | 61 74 65 28 26 77 77 77 |read_cre|ate(&www|
|00002000| 5f 74 68 72 65 61 64 2c | 20 4e 55 4c 4c 2c 20 28 |_thread,| NULL, (|
|00002010| 76 6f 69 64 2a 29 26 77 | 77 77 5f 6d 61 69 6e 2c |void*)&w|ww_main,|
|00002020| 20 4e 55 4c 4c 29 20 3d | 3d 20 2d 31 29 0a 09 7b | NULL) =|= -1)..{|
|00002030| 0a 09 09 70 72 69 6e 74 | 66 28 22 45 72 72 6f 72 |...print|f("Error|
|00002040| 3a 20 63 6f 75 6c 64 20 | 6e 6f 74 20 63 72 65 61 |: could |not crea|
|00002050| 74 65 20 57 57 57 20 74 | 68 72 65 61 64 2e 5c 6e |te WWW t|hread.\n|
|00002060| 22 29 3b 0a 09 09 72 65 | 74 75 72 6e 20 45 58 49 |");...re|turn EXI|
|00002070| 54 5f 46 41 49 4c 3b 0a | 09 7d 0a 0a 09 69 66 20 |T_FAIL;.|.}...if |
|00002080| 28 77 61 6e 74 5f 73 70 | 79 29 0a 09 69 66 20 28 |(want_sp|y)..if (|
|00002090| 70 74 68 72 65 61 64 5f | 63 72 65 61 74 65 28 26 |pthread_|create(&|
|000020a0| 73 70 79 5f 74 68 72 65 | 61 64 2c 20 4e 55 4c 4c |spy_thre|ad, NULL|
|000020b0| 2c 0a 09 09 28 76 6f 69 | 64 2a 29 26 73 70 79 6c |,...(voi|d*)&spyl|
|000020c0| 6f 67 5f 6d 61 69 6e 2c | 20 73 70 79 64 65 76 29 |og_main,| spydev)|
|000020d0| 20 3d 3d 20 2d 31 29 0a | 09 7b 0a 09 09 70 72 69 | == -1).|.{...pri|
|000020e0| 6e 74 66 28 22 45 72 72 | 6f 72 3a 20 63 6f 75 6c |ntf("Err|or: coul|
|000020f0| 64 20 6e 6f 74 20 63 72 | 65 61 74 65 20 73 70 79 |d not cr|eate spy|
|00002100| 20 74 68 72 65 61 64 2e | 5c 6e 22 29 3b 0a 09 09 | thread.|\n");...|
|00002110| 72 65 74 75 72 6e 20 45 | 58 49 54 5f 46 41 49 4c |return E|XIT_FAIL|
|00002120| 3b 0a 09 7d 0a 0a 0a 0a | 09 77 68 69 6c 65 20 28 |;..}....|.while (|
|00002130| 21 73 68 75 74 74 69 6e | 67 5f 64 6f 77 6e 29 20 |!shuttin|g_down) |
|00002140| 70 61 75 73 65 28 29 3b | 0a 0a 0a 0a 09 77 68 69 |pause();|.....whi|
|00002150| 6c 65 20 28 28 69 20 3d | 20 75 70 5f 61 63 63 74 |le ((i =| up_acct|
|00002160| 2b 75 70 5f 64 6e 73 2b | 75 70 5f 77 77 77 2b 75 |+up_dns+|up_www+u|
|00002170| 70 5f 73 70 79 29 29 0a | 09 7b 0a 09 09 70 72 69 |p_spy)).|.{...pri|
|00002180| 6e 74 66 28 22 53 79 6e | 63 69 6e 67 2e 2e 2e 20 |ntf("Syn|cing... |
|00002190| 25 64 20 74 68 72 65 61 | 64 73 5c 6e 22 2c 20 69 |%d threa|ds\n", i|
|000021a0| 29 3b 0a 09 09 75 73 6c | 65 65 70 28 31 30 30 30 |);...usl|eep(1000|
|000021b0| 2a 4d 53 45 43 29 3b 0a | 09 7d 0a 0a 09 69 66 20 |*MSEC);.|.}...if |
|000021c0| 28 61 63 63 74 5f 74 68 | 72 65 61 64 29 20 70 74 |(acct_th|read) pt|
|000021d0| 68 72 65 61 64 5f 6a 6f | 69 6e 28 61 63 63 74 5f |hread_jo|in(acct_|
|000021e0| 74 68 72 65 61 64 2c 20 | 4e 55 4c 4c 29 3b 0a 09 |thread, |NULL);..|
|000021f0| 69 66 20 28 77 77 77 5f | 74 68 72 65 61 64 29 20 |if (www_|thread) |
|00002200| 70 74 68 72 65 61 64 5f | 6a 6f 69 6e 28 77 77 77 |pthread_|join(www|
|00002210| 5f 74 68 72 65 61 64 2c | 20 4e 55 4c 4c 29 3b 0a |_thread,| NULL);.|
|00002220| 09 69 66 20 28 64 6e 73 | 5f 74 68 72 65 61 64 29 |.if (dns|_thread)|
|00002230| 20 70 74 68 72 65 61 64 | 5f 6a 6f 69 6e 28 64 6e | pthread|_join(dn|
|00002240| 73 5f 74 68 72 65 61 64 | 2c 20 4e 55 4c 4c 29 3b |s_thread|, NULL);|
|00002250| 0a 09 69 66 20 28 73 70 | 79 5f 74 68 72 65 61 64 |..if (sp|y_thread|
|00002260| 29 20 70 74 68 72 65 61 | 64 5f 6a 6f 69 6e 28 73 |) pthrea|d_join(s|
|00002270| 70 79 5f 74 68 72 65 61 | 64 2c 20 4e 55 4c 4c 29 |py_threa|d, NULL)|
|00002280| 3b 0a 0a 09 70 74 68 72 | 65 61 64 5f 6d 75 74 65 |;...pthr|ead_mute|
|00002290| 78 5f 64 65 73 74 72 6f | 79 28 26 64 62 5f 6d 75 |x_destro|y(&db_mu|
|000022a0| 74 65 78 29 3b 0a 09 70 | 74 68 72 65 61 64 5f 6d |tex);..p|thread_m|
|000022b0| 75 74 65 78 5f 64 65 73 | 74 72 6f 79 28 26 67 72 |utex_des|troy(&gr|
|000022c0| 61 70 68 5f 6d 75 74 65 | 78 29 3b 0a 0a 09 70 72 |aph_mute|x);...pr|
|000022d0| 69 6e 74 66 28 22 53 79 | 6e 63 65 64 21 20 20 44 |intf("Sy|nced! D|
|000022e0| 75 6d 70 69 6e 67 20 44 | 42 2e 2e 2e 22 29 3b 20 |umping D|B..."); |
|000022f0| 66 66 6c 75 73 68 28 73 | 74 64 6f 75 74 29 3b 0a |fflush(s|tdout);.|
|00002300| 09 73 61 76 65 5f 64 62 | 28 64 62 5f 66 69 6c 65 |.save_db|(db_file|
|00002310| 29 3b 0a 09 70 72 69 6e | 74 66 28 22 64 6f 6e 65 |);..prin|tf("done|
|00002320| 21 5c 6e 22 29 3b 0a 09 | 0a 09 66 72 65 65 28 64 |!\n");..|..free(d|
|00002330| 62 5f 66 69 6c 65 29 3b | 0a 09 66 72 65 65 28 65 |b_file);|..free(e|
|00002340| 72 72 64 62 5f 66 69 6c | 65 29 3b 0a 09 66 72 65 |rrdb_fil|e);..fre|
|00002350| 65 28 64 61 79 6c 6f 67 | 5f 66 69 6c 65 29 3b 0a |e(daylog|_file);.|
|00002360| 09 68 6f 73 74 5f 64 62 | 5f 66 72 65 65 28 29 3b |.host_db|_free();|
|00002370| 0a 09 70 6f 72 74 5f 64 | 62 5f 66 72 65 65 28 29 |..port_d|b_free()|
|00002380| 3b 0a 0a 09 72 65 74 75 | 72 6e 20 45 58 49 54 5f |;...retu|rn EXIT_|
|00002390| 53 55 43 43 45 53 53 3b | 0a 7d 0a 0a 00 00 00 00 |SUCCESS;|.}......|
|000023a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000023b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000023c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000023d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000023e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000023f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002400| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00002410| 54 68 69 73 20 72 65 73 | 6f 75 72 63 65 20 66 6f |This res|ource fo|
|00002420| 72 6b 20 69 6e 74 65 6e | 74 69 6f 6e 61 6c 6c 79 |rk inten|tionally|
|00002430| 20 6c 65 66 74 20 62 6c | 61 6e 6b 20 20 20 00 00 | left bl|ank ..|
|00002440| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002450| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002460| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002470| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002480| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002490| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000024a0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000024b0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000024c0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000024d0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000024e0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|000024f0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002500| 00 00 01 00 00 00 01 00 | 00 00 00 00 00 00 00 1e |........|........|
|00002510| 00 00 00 00 00 00 00 00 | 00 1c 00 1e ff ff 00 00 |........|........|
|00002520| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002530| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002540| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002550| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002560| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00002570| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
+--------+-------------------------+-------------------------+--------+--------+